{include file="public/header" /}
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">充值金额 <span style="color:red;">*</span></label>
        <div class="layui-input-inline">
            <input type="number" name="money" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="2">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支付凭证 <span style="color:red;">*</span></label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="payPic">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
        </div>
        <div class="layui-input-block" id="picBox">
            <img class="upImgBox" src="" alt="" style="height:150px;max-width:150px;margin-top:5px;"/>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
</div>
{include file="public/footer" /}

<script>
    layui.use(['upload','form'], function() {
        var form = layui.form;
        var upload = layui.upload;

        //单图上传
        upload.render({
            elem: '#payPic', //绑定元素
            url: "{:url('admin/upload/upload')}", //上传接口
            field: 'file',
            size: 10240,
            data:{'type':2},
            before: function(obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result) {
                    $('.upImgBox').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res) {
                //上传完毕回调
                if(res.code == 200) {
                    layer.msg(res.msg, {icon: 1});
                    $(".upImgBox").show();
                    $('#picBox').append('<input type="hidden" name="payPic" lay-verify="title" value="' + res.data.pic + '">');
                } else {
                    layer.msg(res.msg, {
                        icon: 5
                    });
                }
            },
            error: function(res) {
                layer.msg('系统旅游去了，稍后再试', {
                    icon: 5
                });
            }
        });
    })
</script>

</script>